home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / qbnws302.zip / LINEDIT.ZIP / EDITDEMO.BAS next >
BASIC Source File  |  1992-03-23  |  9KB  |  230 lines

  1. DEFINT A-Z
  2. '+==================================================================+
  3. '|                           EDITDEMO.BAS                           |
  4. '|                                                                  |
  5. '|  Purpose:  Test program to test the routines in VIDTOOLS.BAS     |
  6. '|                                                                  |
  7. '|  Modules:  LINEEDIT (Main)                                       |
  8. '|            KEYBOARD                                              |
  9. '|            VIDTOOLS                                              |
  10. '|                                                                  |
  11. '|  $INCLUDE file:  'tools.bi'                                      |
  12. '+------------------------------------------------------------------+
  13.  
  14. '+==================================================================+
  15. '|                           DECLARATIONS                           |
  16. '+------------------------------------------------------------------+
  17.  
  18. '$INCLUDE: 'tools.bi'
  19.  
  20. DECLARE SUB LineEdit (Row%, Col%, CurPos%, A$, VwindowSize%, DisplayLen%, CurOffset%, Kee%, Separaters$, Terminators(), EditMask$, AutoTerminate%)
  21.  
  22. CONST True = -1
  23. CONST False = 0
  24.  
  25. '+==================================================================+
  26. '|                        INITIALIZATION  CODE                      |
  27. '+------------------------------------------------------------------+
  28.  
  29.     DIM Frame AS Frame                  'Let's get fancy
  30.     DIM Terminators(10)                 'Make room for ten terminators
  31.    
  32.     '---- Initialize EditStrings
  33.     MaxChoice = 9
  34.     DIM EditStrings$(1 TO MaxChoice)
  35.     DIM CurPostions(1 TO MaxChoice)
  36.     DIM CurOffset%(1 TO MaxChoice)
  37.     DIM EditRow%(1 TO MaxChoice)
  38.     DIM EditCol%(1 TO MaxChoice)
  39.     DIM WindSize%(1 TO MaxChoice)
  40.     DIM DisplaySize%(1 TO MaxChoice)
  41.     DIM EditMask$(1 TO MaxChoice)
  42.     
  43.     '---- Get the default Insert state.
  44.     InsIsOn% = InsertState%
  45.     
  46.     GOSUB DefineEditorVariables
  47.     GOSUB DrawInputScreen
  48.     
  49. '+==================================================================+
  50. '|                              MAIN LOGIC                          |
  51. '+------------------------------------------------------------------+
  52.     
  53.     Choice = 1               'Designate first edit choice
  54.     DO
  55.         '---- AutoTerminate, when true, forces exit at end of field
  56.         AutoTerminate = False
  57.         IF Choice = 5 OR Choice = 6 OR Choice = 7 THEN AutoTerminate = True
  58.        
  59.         '---- Call the Line Editor with appropriate strings, choices, etc.
  60.         LineEdit EditRow%(Choice), EditCol(Choice), CurPostions(Choice), EditStrings$(Choice), WindSize(Choice), DisplaySize(Choice), CurOffset%(Choice), LastKey%, Separaters$, Terminators(), EditMask$(Choice), AutoTerminate%
  61.         
  62.         '---- Restore the screen line before moving on.
  63.         COLOR 15, 5
  64.         LOCATE EditRow%(Choice), EditCol(Choice)
  65.         PRINT LEFT$(EditStrings$(Choice) + SPACE$(DisplaySize(Choice)), DisplaySize(Choice))
  66.  
  67.         BotRowReached = False
  68.         IF Choice = MaxChoice THEN BotRowReached = True
  69.  
  70.         IF LastKey% = -72 THEN Choice = Choice - 1           'Up
  71.         IF Choice < 1 THEN Choice = MaxChoice                'Wrap to last
  72.         IF LastKey = -73 THEN Choice = 1                     'PgUp
  73.  
  74.         IF LastKey% = 13 THEN Choice = Choice + 1            'Enter
  75.         IF LastKey% = -80 THEN Choice = Choice + 1           'Down
  76.         IF Choice > MaxChoice THEN Choice = 1                'Wrap to first
  77.         IF LastKey% = -81 THEN Choice = MaxChoice            'PgDn
  78.         
  79.     LOOP UNTIL ((BotRowReached AND LastKey = 13) OR LastKey = 27)
  80.  
  81.     '---- Restore the screen
  82.     COLOR 7, 0: CLS                         'Clear the screen
  83.     TurnInsertOn InsIsOn%                   'Reset insert to original
  84.  
  85.     '---- Prove changes were made by redisplaying all edit strings
  86.     FOR N = 1 TO MaxChoice
  87.         PRINT EditStrings$(N)
  88.     NEXT
  89.     
  90.     END                                     'And, we're out of here!
  91.  
  92. '+==================================================================+
  93. '|                           SUB ROUTINES                           |
  94. '+------------------------------------------------------------------+
  95.  
  96. DrawInputScreen:
  97.     CLS
  98.  
  99.     Frame.boxType = 2: Frame.filClr = 3     'Define the frame parameters
  100.     Frame.fore = 15: Frame.back = 1
  101.     Frame.lftCol = 1: Frame.rgtCol = 80
  102.     Frame.tRow = 1: Frame.bRow = 13
  103.  
  104.     Box Frame                               'Draw frame for input fields
  105.  
  106.     Frame.back = 4: Frame.filClr = 4
  107.     Frame.tRow = 15: Frame.bRow = 19
  108.     Frame.boxType = 4: Box Frame            'Draw frame for edit help box
  109.  
  110.     COLOR 1, 3                              'Tell user what process is
  111.     LOCATE 3, 32
  112.     PRINT "Edit Data Routine"
  113.  
  114.     LOCATE 11, 3: COLOR 4, 3                'Display brief help message
  115.     PRINT "Use: "; CHR$(24); " "; CHR$(25); " PgUp PgDn.  <Enter> on last entry to process changes.  <Esc>: Abort"
  116.  
  117.     COLOR 15, 3                             'Finish setting up the form
  118.     LOCATE 5, 3: PRINT "Last/First => ";
  119.     LOCATE , 37: PRINT ","
  120.     LOCATE 6, 3: PRINT "Address => "
  121.     LOCATE 7, 3: PRINT "Telephone => (   )   -";
  122.     LOCATE 8, 3: PRINT "Memo => "
  123.     LOCATE 9, 3: PRINT "Save To => "
  124.  
  125.     COLOR 15, 4                             'Messages inside of Help Box
  126.     LOCATE 16, 33: PRINT "Editor Commands"
  127.     LOCATE 17, 4
  128.     PRINT "Scroll line:    ─"; CHR$(16); "    "; CHR$(17); "─    <Home>    <End>    <Ctrl> + ─"; CHR$(16); "    <Ctrl> + "; CHR$(17); "─"
  129.     LOCATE 18, 4
  130.     PRINT "Delete with:    <Delete>    <Backspace>   <Ctrl> + <Home>   <Ctrl> + <End>"
  131.  
  132.     COLOR 15, 5
  133.     FOR N = 1 TO MaxChoice
  134.         LOCATE EditRow%(N), EditCol(N)
  135.         PRINT LEFT$(EditStrings$(N) + SPACE$(DisplaySize(N)), DisplaySize(N))
  136.     NEXT
  137. RETURN
  138.  
  139. DefineEditorVariables:
  140.     '---- Initialize LineEdit's Terminators array.  Terminators are
  141.     '     REQUIRED by the editor.  The zeroeth element of the array
  142.     '     defines how many elements the editor will use.
  143.     Terminators(False) = 5              'Only using first 5 for right now
  144.     Terminators(1) = 27                 'Terminate on Esc key
  145.     Terminators(2) = -72                'Terminate on Up arrow
  146.     Terminators(3) = -80                'Terminate on Down arrow
  147.     Terminators(4) = -73                'Terminate on Page Up
  148.     Terminators(5) = -81                'Terminate on Page Down
  149.  
  150.     '---- These terminators are not used in this demo example.  We've
  151.     '     DIMmed Terminators (10) so 2 more can still be defined.
  152.     Terminators(6) = -132               'Terminate on Ctrl + Page Up
  153.     Terminators(7) = -118               'Terminate on Ctrl + Page Down
  154.     Terminators(8) = -68                'Terminate on F10 key
  155.  
  156.     '---- Initialize LineEdit's word separater string
  157.     Separaters$ = " .:-(){}\/"
  158.  
  159.     '---- Define some data.  Note data could be retrieved from file or DATA
  160.     EditStrings$(1) = "Stone"
  161.     EditRow%(1) = 5
  162.     EditCol(1) = 17
  163.     WindSize(1) = False
  164.     DisplaySize(1) = 20
  165.     '---- "A*" + string "a"
  166.     EditMask$(1) = LEFT$("A*" + STRING$(DisplaySize(1), 97), DisplaySize(1))
  167.     
  168.     EditStrings$(2) = "Lawrence"
  169.     EditRow%(2) = 5
  170.     EditCol(2) = 39
  171.     WindSize(2) = False
  172.     DisplaySize(2) = 20
  173.     '---- "A" + string "*"
  174.     EditMask$(2) = LEFT$("A" + STRING$(DisplaySize(2), 42), DisplaySize(2))
  175.  
  176.     EditStrings$(3) = "1234"
  177.     EditRow%(3) = 6
  178.     EditCol(3) = 14
  179.     WindSize(3) = False
  180.     DisplaySize(3) = 9
  181.     EditMask$(3) = STRING$(DisplaySize(3), "8")
  182.     
  183.     EditStrings$(4) = "Main Street"
  184.     EditRow%(4) = 6
  185.     EditCol(4) = 24
  186.     WindSize(4) = False
  187.     DisplaySize(4) = 35
  188.    
  189.     EditStrings$(5) = "503"
  190.     EditRow%(5) = 7
  191.     EditCol(5) = 17
  192.     WindSize(5) = False
  193.     DisplaySize(5) = 3
  194.     EditMask$(5) = STRING$(DisplaySize(5), "9")
  195.  
  196.     EditStrings$(6) = "756"
  197.     EditRow%(6) = 7
  198.     EditCol(6) = 21
  199.     WindSize(6) = False
  200.     DisplaySize(6) = 3
  201.     EditMask$(6) = STRING$(Dis